<%@ page import="com.ama.utils.SpringUtils" %>
<%@ page import="com.ama.service.PropertyService" %>
<%@ page import="com.ama.service.RoomService" %>
<%@ page import="com.ama.service.BuildService" %>
<%@ page import="com.ama.service.EstateService" %>
<%@ page import="com.ama.service.impl.*" %>
<%@ page import="com.ama.pojo.*" %>
<%@ page import="com.ama.dao.CostDao" %>
<%@ page import="com.ama.utils.NumberUtils" %>
<%--  Created by IntelliJ IDEA.--%>
<%--  User: zez--%>
<%--  Date: 2020/12/20--%>
<%--  Time: 14:47--%>
<%--  To change this template use File | Settings | File Templates.--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <title>费用表</title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="author" content="yinqi">
    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/materialdesignicons.min.css" rel="stylesheet">
    <link href="../css/style.min.css" rel="stylesheet">
</head>

<body>
<%
    Long costId = Long.valueOf(request.getParameter("costId"));
    Staff staff = (Staff) session.getAttribute("user");
    CostDao costDao = SpringUtils.getBean(CostDao.class);
    BedServiceImpl bedService = SpringUtils.getBean(BedServiceImpl.class);
    EstateService estateService = SpringUtils.getBean(EstateServiceImpl.class);
    BuildService buildService = SpringUtils.getBean(BuildServiceImpl.class);
    RoomService roomService = SpringUtils.getBean(RoomServiceImpl.class);
    PropertyService propertyService = SpringUtils.getBean(PropertyServiceImpl.class);

    Cost cost = costDao.selectById(costId);
    Long bedId = cost.getBedId();
    Bed bed = bedService.selectById(bedId);
    Estate estate = estateService.selectById(bed.getEstateId());
    Build build = buildService.selectById(bed.getBuildId());
    Room room = roomService.selectById(bed.getRoomId());
    Property property = propertyService.selectById(estate.getPropertyId());

    double roomcost = NumberUtils.round(room.getRoomRentarea() * room.getRoomPrice() + room.getRoomPublicarea() * 1, 2);

%>
<div class="container-fluid p-t-15">

    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">
                    <%--                    <%=request.getRequestURL()%>?costId=<%=costId%>--%>
                    <div class=" text-center m-b-10"><h4>费用账单</h4></div>
<%--                    <form action="#" method="post" class="guide-box" data-navigateable="true">--%>

                        <div class="row m-b-10">
                            <div class="col-lg-12">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">费用编号</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly
                                           value="<%=cost.getCostNum()%>">
                                </div>
                            </div>
                        </div>

                        <div class="row m-b-10">
                            <div class="col-lg-6">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">员工名称</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly
                                           value="<%=staff.getStaffName()%>">
                                </div>
                            </div>


                            <div class="col-lg-6">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">物业名称</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly
                                           value="<%=property.getPropertyName()%>">
                                </div>
                            </div>
                        </div>

                        <div class="row m-b-10">
                            <div class="col-lg-6">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">房间名称</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly
                                           value="<%=room.getRoomName()%>">
                                </div>
                            </div>


                            <div class="col-lg-6">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">铺位名称</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly
                                           value="<%=bed.getBedName()%>">
                                </div>
                            </div>
                        </div>

                        <div class="row m-b-10">
                            <div class="col-lg-12">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">房屋租金</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly value="<%=roomcost%>">
                                </div>
                            </div>
                        </div>

                        <div class="row m-b-10">
                            <div class="col-lg-6">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">水费</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly
                                           value="<%=cost.getCostWater()%>">
                                </div>
                            </div>

                            <div class="col-lg-6">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">电费</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly
                                           value="<%=cost.getCostElec()%>">
                                </div>
                            </div>
                        </div>

                        <div class="row m-b-10">
                            <div class="col-lg-6">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">税率</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly
                                           value="<%=cost.getCostTax()%>">
                                </div>
                            </div>

                            <div class="col-lg-6">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">税费金额</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly
                                           value="<%=cost.getCostTaxamount()%>">
                                </div>
                            </div>
                        </div>

                        <div class="row m-b-10">
                            <div class="col-lg-6">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">费用总金额</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly
                                           value="<%=NumberUtils.round(cost.getCostAmount()*3,2)%>(三个月费用)">
                                </div>
                            </div>

                            <div class="col-lg-6">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">应收金额</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly
                                           value="<%=NumberUtils.round(cost.getCostAmount()*3,2)%>(三个月费用)">
                                </div>
                            </div>
                        </div>

                        <div class="row m-b-10">
                            <div class="col-lg-12">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">付款日期</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly
                                           value="<%=cost.getCostPaydate()%>">
                                </div>
                            </div>
                        </div>

                        <div class="row m-b-10">
                            <div class="col-lg-6">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">费用起始日</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly
                                           value="<%=cost.getCostCreatdate()%>">
                                </div>
                            </div>

                            <div class="col-lg-6">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">费用截止日</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly
                                           value="<%=cost.getCostEnddate()%>">
                                </div>
                            </div>
                        </div>

                        <div class="row m-b-10">
                            <div class="col-lg-1">
                                <div class="form-group">
                                    <span class="input-group-btn">
                                          <button class="btn btn-default" type="button">费用状态</button>
                                    </span>
                                </div>
                            </div>
                            <div class="col-lg-1">
                                <%
                                    if (cost.getCostState() == 0) {
                                %>
                                <button class="btn btn-warning btn-w-md">等待审批</button>
                                <%
                                } else if (cost.getCostState() == 1) {
                                %>
                                <button class="btn btn-success btn-w-md">已缴费</button>
                                <%
                                } else if (cost.getCostState() == -1) {
                                %>
                                <button class="btn btn-warning btn-w-md">待缴费</button>
                                <%
                                } else if (cost.getCostState() == -2) {
                                %>
                                <button class="btn btn-danger btn-w-md">已超时！尽快缴费</button>
                                <%
                                } else if (cost.getCostState() == -3) {
                                %>
                                <button class="btn btn-danger btn-w-md">已取消</button>
                                <%
                                    }
                                %>
                            </div>


                        </div>

                        <div class="row m-b-10">
                            <div class="col-lg-12">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                      <button class="btn btn-default" type="button">备注</button>
                                    </span>
                                    <input type="text" class="form-control bg-white" readonly
                                           value="<%=NumberUtils.round(cost.getCostAmount()*3,2)%>---(租用面积*房间单价+公摊面积*1+水电费+)*3个月*税率">
                                </div>
                            </div>
                        </div>


                        <div class="nav-step-button">
                            <%--                            <a class="btn btn-secondary" hidden="hidden" disabled="" data-wizard="prev" type="button" href="s_bed.jsp?room=<%=bed.getRoomId()%>">上一步</a>--%>
                            <a class="btn btn-secondary" href="/cancelApply">打印申请单</a>

                            <button type="button" class="btn btn-primary" data-toggle="modal"<%
                                if (cost.getCostState() == 0 || cost.getCostState() == 1 || cost.getCostState() == -3) {
                            %>
                                    disabled
                                    <%
                                        }
                                    %>
                                    data-target=".bs-example-modal-sm">账单缴费
                            </button>

                                <div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
                                     aria-labelledby="mySmallModalLabel">
                                    <div class="modal-dialog modal-sm" role="document">
                                        <div class="modal-content">
                                            <form name="pay_form" action="/payCost">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal"
                                                        aria-label="Close">
                                                    <span aria-hidden="true">×</span></button>
                                                <h4 class="modal-title" id="">账单缴费</h4>
                                                <div class="modal-body">
                                                    <img class="d-inline-block" src="../images/paycost.jpg">
                                                    <label class="form-group">缴费金额</label>
                                                    <input type="text" name="pay"
                                                           value="<%=cost.getCostShouldpay()%>"
                                                           class="form-control">
                                                </div>
                                            </div>
                                            <script>
                                                function paycost(){
                                                    document.pay_form.action="/payCost";
                                                    console.log("pay-----")
                                                    document.pay_form.submit();
                                                }
                                            </script>
                                            <div class="modal-footer">
                                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                                <button onclick="paycost()" class="btn btn-primary">提交</button>
                                            </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>



<%--                    </form>--%>
                </div>
            </div>
        </div>
    </div>


</div>


<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/main.min.js"></script>

<!--图表插件-->
<script type="text/javascript" src="../js/Chart.js"></script>
<script type="text/javascript"></script>

</body>
</html>